<?php

class IndexAction extends Action
{
    public function index()
    {
    	$configModel = M("Config");
    	$array = $configModel->select();
		$str = $array[0]['config_value'];
		$web_name = $array[1]['config_value'];
		$banquan = $array[3]['config_value'];
		$developer = $array[4]['config_value'];
    	
    	$moduleModel = M("Module");
    	$arrar = $moduleModel->select();
    	$module_1 = $arrar[0]['module_name'];
    	$module_2 = $arrar[1]['module_name'];
    	$module_3 = $arrar[2]['module_name'];
    	$module_4 = $arrar[3]['module_name'];
    	$module_5 = $arrar[4]['module_name'];
    	$module_6 = $arrar[5]['module_name'];
    	$module_7 = $arrar[6]['module_name'];
    	$module_8 = $arrar[7]['module_name'];
    	$module_9 = $arrar[8]['module_name'];
    	$module_10 = $arrar[9]['module_name'];
    	$module_11 = $arrar[10]['module_name'];
    	$module_12 = $arrar[11]['module_name'];
    	$module_13 = $arrar[12]['module_name'];
    	$module_14 = $arrar[13]['module_name'];
    	$module_15 = $arrar[14]['module_name'];
    	$module_16 = $arrar[15]['module_name'];
    	$module_17 = $arrar[16]['module_name'];
    	$module_18 = $arrar[17]['module_name'];
    	$module_19 = $arrar[18]['module_name'];
    	$module_20 = $arrar[19]['module_name'];
    	$module_21 = $arrar[20]['module_name'];
    	$module_22 = $arrar[21]['module_name'];
    	
    	$this->assign("kechengjianjie",$str);
		$this->assign("webName",$web_name);
		$this->assign('banquan',$banquan);
		$this->assign('developer',$developer);
		
		
		$this->assign("kechengjiankuang",$module_1);
		$this->assign("zhujiangjiaoshi",$module_2);
		$this->assign("jiaoxueneirong",$module_3);
		$this->assign("jiaoxuetiaojian",$module_4);
		$this->assign("jiaoxuecankao",$module_5);
		$this->assign("jiaoxueluxiang",$module_6);
		$this->assign("jiaoxuekexueyanjiu",$module_7);
		$this->assign("shenbaoshu",$module_8);
		$this->assign("liguangli",$module_9);
		$this->assign("shenyuchun",$module_10);
		$this->assign("chengang",$module_11);
		$this->assign("liuchuwu",$module_12);
		$this->assign("zhuchunhua",$module_13);
		$this->assign("jiaoxuedagang",$module_14);
		$this->assign("lilunjiaoxue",$module_15);
		$this->assign("shijianjiaoxue",$module_16);
		$this->assign("jiaocai",$module_17);
		$this->assign("shiyanshebei",$module_18);
		$this->assign("zuoye",$module_19);
		$this->assign("guowaixiangguanjiaocheng",$module_20);
		$this->assign("keyanhegaigeketi",$module_21);
		$this->assign("jiangxiang",$module_22);
        $this->display();
    }
    
	public function left_content(){
        $this->display();
	}
	
    public function kechengjiankuang(){
    	$moduleModel = M("Module");
    	$moduleData = $moduleModel->find(C('kechengjiankuang'));
    	$moduleData = $moduleModel->find($condition);
    	$this->assign("moduleName",$moduleData['module_name']);
    	$this->assign("kechengjiankuang",$moduleData['module_value']);
        $this->display();
    }

    public function zhujiangjiaoshi(){
    	$moduleModel = M("Module");
    	$moduleData = $moduleModel->find(C('zhujiangjiaoshi'));
    	$this->assign("moduleName",$moduleData['module_name']);
    	
    	$moduleData = $moduleModel->find(C('liguangli'));
    	$this->assign("liguangli",$moduleData['module_value']);
    	
    	$moduleData = $moduleModel->find(C('shenyuchun'));
    	$this->assign("shenyuchun",$moduleData['module_value']);
    	
    	$moduleData = $moduleModel->find(C('chengang'));
    	$this->assign("chengang",$moduleData['module_value']);
    	
    	$moduleData = $moduleModel->find(C('liuchuwu'));
    	$this->assign("liuchuwu",$moduleData['module_value']);
    	
    	$moduleData = $moduleModel->find(C('zhuchunhua'));
    	$this->assign("zhuchunhua",$moduleData['module_value']);
        $this->display();
    }

    public function jiaoxueneirong(){
    	$moduleModel = M("Module");
    	$moduleData1 = $moduleModel->find(C('jiaoxueneirong'));
    	$this->assign("moduleName1",$moduleData1['module_name']);
    	$moduleData2 = $moduleModel->find(C('jiaoxuedagang'));
    	$this->assign("moduleName2",$moduleData2['module_name']);
    	$moduleData3 = $moduleModel->find(C('lilunjiaoxue'));
    	$this->assign("moduleName3",$moduleData3['module_name']);
    	$moduleData4 = $moduleModel->find(C('shijianjiaoxue'));
    	$this->assign("moduleName4",$moduleData4['module_name']);
    	//读取 教案 文件夹里所有的文档
    	$dir1 = "../courses/public/download/jiaoxueneirong/lilunjiaoxue/jiaoan";
    	$fileDir_jiaoan = $this->getDir($dir1);
    	$fileName_jiaoan = $this->delDirSuffix($fileDir_jiaoan);
    	//理论教学PPT
    	$dir2 = "../courses/public/download/jiaoxueneirong/lilunjiaoxue/ppt";
    	$fileDir_ppt = $this->getDir($dir2);
    	$fileName_ppt = $this->delDirSuffix($fileDir_ppt);
    	//科技论文
    	$dir3 = "../courses/public/download/jiaoxueneirong/lilunjiaoxue/kejilunwen";
    	$fileDir_lunwen = $this->getDir($dir3);
    	$fileName_lunwen = $this->delDirSuffix($fileDir_lunwen);
    	//实践教学  图片
    	$dir4 = "../courses/public/images/shijianjiaoxue/pic";
    	$imgDir_shijian = $this->getDir($dir4);
    	
    	
    	
    	$this->assign("jiaoxuedagangURL","/courses/public/jiaoxuedagang.swf");
    	$this->assign("fileName_jiaoan",$fileName_jiaoan);
    	$this->assign("fileName_ppt",$fileName_ppt);
    	$this->assign("fileName_lunwen",$fileName_lunwen);
    	$this->assign("imgDir_shijian",$imgDir_shijian);
        $this->display();
    }

    public function jiaoxuetiaojian(){
    	$moduleModel = M("Module");
    	$moduleData = $moduleModel->find(C('jiaoxuetiaojian'));
    	$this->assign("moduleName",$moduleData['module_name']);
    	//教材图片
    	$dir_b = "../courses/public/images/slidethumbs/pic_b";
    	$dir_s = "../courses/public/images/slidethumbs/pic_s";
    	$imgDir_b = $this->getDir($dir_b);
    	$imgName_b = $this->delDirSuffix($imgDir_b);
    	$imgDir_s = $this->getDir($dir_s);
    	//实验设备
    	$dir_shiyan = "../courses/public/images/shiyanshebei";
    	$imgDir_shiyan = $this->getDir($dir_shiyan);
    	
    	
    	$this->assign("imgDir_b",$imgDir_b);
    	$this->assign("imgDir_s",$imgDir_s);
    	$this->assign("imgDir_shiyan",$imgDir_shiyan);
        $this->display();
    }

    public function jiaoxuecankao(){
    	$moduleModel = M("Module");
    	$moduleData1 = $moduleModel->find(C('jiaoxuecankao'));
    	$this->assign("moduleName1",$moduleData1['module_name']);
    	$moduleData2 = $moduleModel->find(C('zuoye'));
    	$this->assign("moduleName2",$moduleData2['module_name']);
    	$moduleData3 = $moduleModel->find(C('guowaixiangguanjiaocheng'));
    	$this->assign("moduleName3",$moduleData3['module_name']);
    	//06作业
    	$dir_06 = "../courses/public/download/jiaoxuecankao/zuoye/2006";
    	$zuoyeDir_06 = $this->getDir($dir_06);
    	$zuoye_06 = $this->delDirSuffix($zuoyeDir_06);
    	//07作业
    	$dir_07 = "../courses/public/download/jiaoxuecankao/zuoye/2007";
    	$zuoyeDir_07 = $this->getDir($dir_07);
    	$zuoye_07 = $this->delDirSuffix($zuoyeDir_07);
    	//09作业
    	$dir_09 = "../courses/public/download/jiaoxuecankao/zuoye/2009";
    	$zuoyeDir_09 = $this->getDir($dir_09);
    	$zuoye_09 = $this->delDirSuffix($zuoyeDir_09);
    	//10作业
    	$dir_10 = "../courses/public/download/jiaoxuecankao/zuoye/2010";
    	$zuoyeDir_10 = $this->getDir($dir_10);
    	$zuoye_10 = $this->delDirSuffix($zuoyeDir_10);
    	//12作业
    	$dir_12 = "../courses/public/download/jiaoxuecankao/zuoye/2012";
    	$zuoyeDir_12 = $this->getDir($dir_12);
    	$zuoye_12 = $this->delDirSuffix($zuoyeDir_12);
    	//学生自己的实验
    	$dir_xuesheng = "../courses/public/download/jiaoxuecankao/zuoye/xuesheng";
    	$zuoyeDir_xuesheng = $this->getDir($dir_xuesheng);
    	$zuoye_xuesheng = $this->delDirSuffix($zuoyeDir_xuesheng);
    	//国外  内分泌学
    	$dir_guowai1= "../courses/public/download/jiaoxuecankao/guowai/neifenmixue";
    	$guowaiDir_1 = $this->getDir($dir_guowai1);
    	$guowai_1 = $this->delDirSuffix($guowaiDir_1);
    	//国外  动物生理学
    	$dir_guowai2= "../courses/public/download/jiaoxuecankao/guowai/dongwushenglixue";
    	$guowaiDir_2 = $this->getDir($dir_guowai2);
    	$guowai_2 = $this->delDirSuffix($guowaiDir_2);
    	//国外  生理学实验
    	$dir_guowai3= "../courses/public/download/jiaoxuecankao/guowai/shenglixueshiyan";
    	$guowaiDir_3 = $this->getDir($dir_guowai3);
    	$guowai_3 = $this->delDirSuffix($guowaiDir_3);
    	
    	
    	$this->assign("zuoye_06",$zuoye_06);
    	$this->assign("zuoye_07",$zuoye_07);
    	$this->assign("zuoye_09",$zuoye_09);
    	$this->assign("zuoye_10",$zuoye_10);
    	$this->assign("zuoye_12",$zuoye_12);
    	$this->assign("zuoye_xuesheng",$zuoye_xuesheng);
    	$this->assign("guowai_1",$guowai_1);
    	$this->assign("guowai_2",$guowai_2);
    	$this->assign("guowai_3",$guowai_3);
        $this->display();
    }

    public function jiaoxueluxiang(){
    	$moduleModel = M("Module");
    	$moduleData = $moduleModel->find(C('jiaoxueluxiang'));
    	$this->assign("moduleName",$moduleData['module_name']);
    	
    	$player = "http://www.banchen.com/images/flv.swf";
    	$movie = "http://localhost/courses/public/video.flv";
    	$this->assign("player",$player);
    	$this->assign("movie",$movie);
        $this->display();
    }

    public function jiaoxuekexueyanjiu(){
    	$moduleModel = M("Module");
    	$moduleData1 = $moduleModel->find(C('jiaoxuekexueyanjiu'));
    	$this->assign("moduleName1",$moduleData1['module_name']);
    	$moduleData2 = $moduleModel->find(C('keyanhegaigeketi'));
    	$this->assign("moduleName2",$moduleData2['module_name']);
    	$moduleData3 = $moduleModel->find(C('jiangxiang'));
    	$this->assign("moduleName3",$moduleData3['module_name']);
    	
    	$moduleData = $moduleModel->find(21);
    	$this->assign("keyanhegaigeketi",$moduleData['module_value']);
    	$moduleData = $moduleModel->find(22);
    	$this->assign("jiangxiang",$moduleData['module_value']);
        $this->display();
    }

    public function shenbaoshu(){
    	$moduleModel = M("Module");
    	$moduleData = $moduleModel->find(C('shenbaoshu'));
    	$this->assign("moduleName",$moduleData['module_name']);
        $this->display();
    }
    
    public function showSwf(){
    	$fileName = $_GET['file'];
    	$dirType = $_GET['dir'];
    	switch ($dirType){
    		case 1:
    			$dir = "/courses/public/download/jiaoxuecankao/zuoye/xuesheng/";
    			break;
    		case 2:
    			$dir = "/courses/public/download/jiaoxuecankao/guowai/neifenmixue/";
    			break;
    		case 3:
    			$dir = "/courses/public/download/jiaoxuecankao/guowai/dongwushenglixue/";
    			break;
    		case 4:
    			$dir = "/courses/public/download/jiaoxuecankao/guowai/shenglixueshiyan/";
    			break;
    		case 6:
    			$dir = "/courses/public/download/jiaoxuecankao/zuoye/2006/";
    			break;
    		case 7:
    			$dir = "/courses/public/download/jiaoxuecankao/zuoye/2007/";
    			break;
    		case 9:
    			$dir = "/courses/public/download/jiaoxuecankao/zuoye/2009/";
    			break;
    		case 10:
    			$dir = "/courses/public/download/jiaoxuecankao/zuoye/2010/";
    			break;
    		case 12:
    			$dir = "/courses/public/download/jiaoxuecankao/zuoye/2012/";
    			break;
    		case 20:
    			$dir = "/courses/public/download/jiaoxueneirong/lilunjiaoxue/ppt/";
    			break;
    		case 21:
    			$dir = "/courses/public/download/jiaoxueneirong/lilunjiaoxue/kejilunwen/";
    			break;
    		case 22:
    			$dir = "/courses/public/download/jiaoxueneirong/lilunjiaoxue/jiaoan/";
    			break;
    	}
    	$fileDir = $dir.$fileName.".swf";
    	$this->assign("fileName",$fileName);
    	$this->assign("fileDir",$fileDir);
    	$this->display();
    }
    /**
    +----------------------------------------------------------
    * 探针模式
    +----------------------------------------------------------
    */
    public function checkEnv()
    {
        load('pointer',THINK_PATH.'/Tpl/Autoindex');//载入探针函数
        $env_table = check_env();//根据当前函数获取当前环境
        echo $env_table;
    }
    /**
    +----------------------------------------------------------
    * 获取文件目录列表,该方法返回数组
    +----------------------------------------------------------
    */
	private function getDir($dir) {
		$fileArray[]=NULL;
		if (false != ($handle = opendir ( $dir ))) {
			$i=0;
			while ( false !== ($file = readdir ( $handle )) ) {
				//去掉"“.”、“..”以及带“.xxx”后缀的文件
				if ($file != "." && $file != ".."&&strpos($file,".")) {
					$file = iconv("gbk", "utf-8" , $file);
					$fileArray[$i]= $file;
					if($i==100){
						break;
					}
					$i++;
				}
			}
			//关闭句柄
			closedir ( $handle );
		}
		return $fileArray;
	}
	private function delDirSuffix($array){
		for ($i = 0;$i < count($array);$i++){
			list($name,$suffix) =  explode(".", $array[$i],2);
			$array[$i] = $name;
		}
		return $array;
	}
}
?>